/**
 * 
 */
package org.wicket.jbpm.engine.spring;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.exe.ProcessInstance;
import org.wicket.jbpm.engine.exception.WicketJbpmException;
import org.wicket.jbpm.engine.workflow.WfPath;
import org.wicket.jbpm.engine.workflow.WfTask;

/**
 * @author Emmanuel Nollase - emanux
 * created: Jun 27, 2009 - 2:04:21 PM
 */
public interface JbpmCoreEngine {
	
    	/**
    	 * Signal the workflow task to next transition w/ variables to set
    	 * @param pathId
    	 * @param transition
    	 * @param vars
    	 * @return
    	 * @throws WicketJbpmException
    	 */
    	WfPath signalTask(final String pathId,final String transition,final Map<String, Serializable> vars) throws WicketJbpmException;
    	
    	/**
    	 * Signal the workflow task to next transition w/ variables to set
    	 * @param pathId
    	 * @param vars
    	 * @return
    	 * @throws WicketJbpmException
    	 */
    	WfPath signalTask(final String pathId,final Map<String, Serializable> vars) throws WicketJbpmException;
	
    	/**
	 * Signal the workflow task to next transition
	 * @param pathId
	 * @param transition
	 * @return
	 * @throws WicketJbpmException
	 */
	WfPath signalTask(final String pathId,final String transition) throws WicketJbpmException;
	
	/**
	 * Signal the workflow task to next transition
	 * @param pathId
	 * @return
	 * @throws WicketJbpmException
	 */
	WfPath signalTask(final String pathId) throws WicketJbpmException;
	
	/**
	 * End the workflow task
	 * @param taskInstanceId
	 * @param comments
	 * @param vars
	 * @return
	 * @throws WicketJbpmException
	 */
	WfTask endTask(final String taskInstanceId,
	  		       final String comments,final Map<String,Serializable> vars) throws WicketJbpmException;
	
	/**
	 * End the workflow task
	 * @param taskInstanceId
	 * @param comments
	 * @return
	 * @throws WicketJbpmException
	 */
	WfTask endTask(final String taskInstanceId, final String comments) throws WicketJbpmException;
	
	/**
	 * End the Workflow Process. It will delete the particular workflow
	 * @param processInstId
	 * @return
	 * @throws WicketJbpmException
	 */
	ProcessInstance endJbpmWorkflow(final String processInstId) throws WicketJbpmException;
	
	/**
	 * Re-Assign workflow task to other users.
	 * @param taskInstanceId
	 * @param pooledActors
	 * @param comments
	 * @return
	 * @throws WicketJbpmException
	 */
	WfTask reassignTask(final String taskInstanceId,final String[] pooledActors,final String comments) throws WicketJbpmException;
	
	/**
	 * Gets the leaving transition/s for a task.
	 * @param taskInstanceId - task instance
	 * @return - list of leaving transition
	 */
	List<String> getTaskLeavingTransition(final String taskInstanceId);
	
	/**
	 * Handler for timer to end the timed task
	 * @param context
	 * @throws WicketJbpmException
	 */
	void endTimerTask(final ExecutionContext context) throws WicketJbpmException;
	
	/**
	 * Get all assigned task for a user
	 * @param user
	 * @return
	 */
	List<WfTask> getAssignedTasks(final String user) throws WicketJbpmException;;
	
	/**
	 * Start the jBPM workflow process from a process definition
	 * @param processDef
	 * @param user
	 * @param param
	 * @return
	 * @throws WicketJbpmException
	 */
	WfPath startProcessInstance(ProcessDefinition processDef, String user, Map<String, Serializable> param) throws WicketJbpmException;;
}
